package edu.sctu.alex.June.day20150626;


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

/**
 * Created by alex on 2015/6/28.
 */
public class WebJsonInfo {


    public String getJsonInfo(String path){

        StringBuffer jsonInfo = new StringBuffer();

        String line= "";

        try {
            URL url = new URL(path);

            URLConnection uRLConnection = url.openConnection();

            InputStream inputStream = uRLConnection.getInputStream();

            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));

            while ((line = bufferedReader.readLine()) != null) {

                jsonInfo.append(line);
            }

        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return jsonInfo.toString();
    }
}
